[General] Update button's animation duration props#4046
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new minimumAnimationDuration prop to GestureHandlerButton to ensure the “pressed in” visual state remains visible for at least a minimum time (mitigating native touch delays inside scrollables that can cause immediate press-out).
Changes:
- Introduces
minimumAnimationDurationto the button’s codegen spec and TS props. - Implements minimum-duration press-out deferral on Web, iOS, and Android.
- Updates the common-app underlay example to exercise the new prop.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-native-gesture-handler/src/specs/RNGestureHandlerButtonNativeComponent.ts | Adds minimumAnimationDuration to native component codegen props with a default. |
| packages/react-native-gesture-handler/src/components/GestureHandlerButton.web.tsx | Implements min-duration press-out deferral for web button visuals. |
| packages/react-native-gesture-handler/src/components/GestureHandlerButton.tsx | Documents the new prop on the public ButtonProps interface. |
| packages/react-native-gesture-handler/apple/RNGestureHandlerButtonComponentView.mm | Wires the new prop from Fabric props into the native button view. |
| packages/react-native-gesture-handler/apple/RNGestureHandlerButton.mm | Adds iOS minimum-duration handling between press-in and press-out animations. |
| packages/react-native-gesture-handler/apple/RNGestureHandlerButton.h | Exposes minimumAnimationDuration on the native button class. |
| packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt | Adds Android prop setter + min-duration delayed press-out implementation. |
| apps/common-app/src/new_api/components/button_underlay/index.tsx | Updates example props to demonstrate minimumAnimationDuration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…-animation-duration
minimumAnimationDuration prop to button componentThere was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0d51d22 to
8cd97a9
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
Native platforms delay touches when the button is inside a ScrollView. This may cause situations where press-out is triggered immediately after press-in, effectively running with no animation.
This PR:
animationDurationtopressAndHoldAnimationDurationtapAnimationDurationpressAndHoldAnimationDurationdefaults totapAnimationDurationwhen unspecified;tapAnimationDurationdefaults to 100ms.Press out handler now has three branches:
pressAndHoldAnimationDuration-> press out animation is started immediately with the duration ofpressAndHoldAnimationDurationtapAnimationDuration,pressAndHoldAnimationDuration] (*2 so there's at least half oftapAnimationDurationfor the remaining animation) -> press out animation is started immediately with the duration of the press so fartapAnimationDuration / 2-> pressIn animation is played fully in the remaining time intapAnimationDuration, and pressOut is scheduled after with the duration oftapAnimationDurationTest plan
Updated the button underlay example